#!/usr/bin/env python
##################################################
# Gnuradio Python Flow Graph
# Title: Up Converter
# Generated: Thu Jan  3 15:52:05 2013
##################################################

from gnuradio import gr
from gnuradio.gr import firdes

class up_converter(gr.hier_block2):

	def __init__(self, samp_rate=32e3, base_freq=5e3):
		gr.hier_block2.__init__(
			self, "Up Converter",
			gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
			gr.io_signature(1, 1, gr.sizeof_float*1),
		)

		##################################################
		# Parameters
		##################################################
		self.samp_rate = samp_rate
		self.base_freq = base_freq

		##################################################
		# Blocks
		##################################################
		self.gr_sig_source_x_0_0 = gr.sig_source_f(samp_rate, gr.GR_SIN_WAVE, base_freq, 1, 0)
		self.gr_sig_source_x_0 = gr.sig_source_f(samp_rate, gr.GR_COS_WAVE, base_freq, 1, 0)
		self.gr_multiply_xx_0_0 = gr.multiply_vff(1)
		self.gr_multiply_xx_0 = gr.multiply_vff(1)
		self.gr_complex_to_float_0 = gr.complex_to_float(1)
		self.gr_add_xx_0 = gr.add_vff(1)

		##################################################
		# Connections
		##################################################
		self.connect((self, 0), (self.gr_complex_to_float_0, 0))
		self.connect((self.gr_complex_to_float_0, 0), (self.gr_multiply_xx_0, 1))
		self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 0))
		self.connect((self.gr_sig_source_x_0_0, 0), (self.gr_multiply_xx_0_0, 1))
		self.connect((self.gr_complex_to_float_0, 1), (self.gr_multiply_xx_0_0, 0))
		self.connect((self.gr_multiply_xx_0, 0), (self.gr_add_xx_0, 0))
		self.connect((self.gr_multiply_xx_0_0, 0), (self.gr_add_xx_0, 1))
		self.connect((self.gr_add_xx_0, 0), (self, 0))

	def get_samp_rate(self):
		return self.samp_rate

	def set_samp_rate(self, samp_rate):
		self.samp_rate = samp_rate
		self.gr_sig_source_x_0.set_sampling_freq(self.samp_rate)
		self.gr_sig_source_x_0_0.set_sampling_freq(self.samp_rate)

	def get_base_freq(self):
		return self.base_freq

	def set_base_freq(self, base_freq):
		self.base_freq = base_freq
		self.gr_sig_source_x_0.set_frequency(self.base_freq)
		self.gr_sig_source_x_0_0.set_frequency(self.base_freq)


